<%@page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市订单管理系统</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css"/>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/public.css"/>
</head>
<body>
<div class="location">
    <strong>你现在所在的位置是:</strong>
    <span>密码修改页面</span>
</div>
<div class="providerAdd">
    <form id="userForm">
       <div class="info"></div>
       <div>
           <label for="password">旧密码：</label>
           <input type="password" name="password" id="password" value="">
           <font color="red"></font>
       </div>
       <div>
           <label for="newPassword">新密码：</label>
           <input type="password" name="newpassword" id="newpassword" value="">
           <font color="red"></font>
       </div>
       <div>
           <label for="rnewpassword">确认新密码：</label>
           <input type="password" name="rnewpassword" id="rnewpassword" value="">
           <font color="red"></font>
       </div>
       <div class="providerAddBtn">
           <input type="button" id="save" value="保存" />
           <input type="button" id="back" value="返回"/>
       </div>
    </form>
</div>

<footer class="footer">
    版权归北大青鸟
</footer>
</body>

<!-- 保存当前页的后台路径和参数 -->
<c:set var="urlLoading" value="/user/modifyPassword" scope="session"></c:set>
<c:set var="paramLoading" value="id=${loginInfo.id }&page=modifyPassword.jsp" scope="session"></c:set>

<script type="text/javascript">
$(".providerAddBtn :button[value='保存']").bind("click", function() {
	/* 表单验证 */
	if($("#userForm [name = 'password']").val() != "${loginInfo.password}"){
		alert("当前密码与旧密码不一致,请重新输入! ");
		//清空
		$("#userForm [name = 'password']").val("");
		$("#userForm [name = 'newpassword']").val("");
		$("#userForm [name = 'rnewpassword']").val("");
		return;
	}
	if($("#userForm [name = 'newpassword']").val() == "${loginInfo.password}" && $("#userForm [name = 'rnewpassword']").val() == "${loginInfo.password}"){
		alert("新密码与旧密码一致,请重新输入! ");
		//清空
		$("#userForm [name = 'password']").val("");
		$("#userForm [name = 'newpassword']").val("");
		$("#userForm [name = 'rnewpassword']").val("");
		return;
	}
	if($("#userForm [name = 'newpassword']").val() != $("#userForm [name = 'rnewpassword']").val()){
		alert("要修改的两次密码输入不一致,请重新输入! ");
		//清空
		$("#userForm [name = 'password']").val("");
		$("#userForm [name = 'newpassword']").val("");
		$("#userForm [name = 'rnewpassword']").val("");
		return;
	}
	if(!confirm("确定保存吗?")) return;
	
	toJump("${pageContext.request.contextPath}/user/modifyPassword", 
			$("#userForm").serialize()+"&id=${loginInfo.id}", "#mainframe");
});
$(".providerAddBtn :button[value='返回']").bind("click", function() {
	toJump("${pageContext.request.contextPath}/user/query", 
			"curr=1&realName=${realName}&roleId=${roleId}", "#mainframe");
});
</script>
</html>
